<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="图像ID" prop="imageId">
        <el-input
          v-model="queryParams.imageId"
          placeholder="请输入图像ID"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否合规" prop="conclusion">
        <el-input
          v-model="queryParams.conclusion"
          placeholder="请输入是否合规"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="违规简介" prop="imageMsg">
        <el-input
          v-model="queryParams.imageMsg"
          placeholder="请输入违规简介"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['filter:imagefilter:remove']"
        >删除</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="imagefilterList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="图像ID" align="center" prop="imageId" />
      <el-table-column label="图像" align="center" prop="imagePath" >
        <template slot-scope="scope">
          <img :src="getImgUrl(scope.row.imagePath)" width="40" height="40" class="head_pic"/>
        </template>
      </el-table-column>
      <el-table-column label="是否合规" align="center" prop="conclusion" />
      <el-table-column label="违规简介" align="center" prop="imageMsg" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['filter:imagefilter:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import { listImagefilter, getImagefilter, delImagefilter, addImagefilter, updateImagefilter, exportImagefilter } from "@/api/filter/imagefilter";
import API_CONFIG from '../../../../vue.config'
export default {
  name: "Imagefilter",
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 图片审核归集表格数据
      imagefilterList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        imageId: null,
        imagePath: null,
        conclusion: null,
        imageMsg: null
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /**获取imgURL地址*/
    getImgUrl(data){
      return API_CONFIG.devServer.proxy[process.env.VUE_APP_BASE_API].target + data
    },
    /** 查询图片审核归集列表 */
    getList() {
      this.loading = true;
      listImagefilter(this.queryParams).then(response => {
        this.imagefilterList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.imageId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const imageIds = row.imageId || this.ids;
      this.$confirm('是否确认删除图片审核归集编号为"' + imageIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delImagefilter(imageIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
    },
  }
};
</script>
